<?php
namespace app\mobile\controller;

use app\model\Theme; 
use app\model\Worker; 
use app\model\Fans; 

class WWechatgroup extends Base
{
    public function W_wechatgroup()
    {
global $_G, $_P;
$fans = $this->checkuser();
$themeid = intval($_P['themeid']);
if ($themeid < 0) {
    return_msg('管理后台地址不正确');
}
$system = $_G['system'];
$theme = Theme::getThemeById($themeid);
$config = Theme::getConfig($themeid);
if (empty($theme['id'])) {
    return_msg('管理后台地址不正确');
}
$myworker = Worker::getThemeWorkerByOpenidNew($_G['openid'], $themeid);
if (!(!$system['is_multiple_merchants'] || $config['showshop'] == 0 || ($system['is_multiple_merchants'] && $config['showshop'] == $myworker['company']))) {
    $myworker = "";
}
if (empty($myworker) || $myworker['level']>3) {
    return_msg('您不是员工,无权访问');
}
$msg = Worker::gethoutaistats();
if (!empty($msg)) {
    return_msg($msg);
}

$result = Fans::W_wechatgroup($system,$myworker);

foreach ($result['list'] as $index => $row) {
    $result['list'][$index]['url'] = "/" . createMobileUrl('w_wechatgroup_add',array("themeid"=>$themeid,"id"=>$row['id']));
}
if ($_P['show'] == 'get') {
    return_msg($result, '', 'ajax');
} else {

    $return_clicent = get_defined_vars();
return view('/yxworker/w_wechatgroup', $return_clicent);
}
}
}